<?php

class Application_Form_Register extends Zend_Form
{
	
	protected $area = array(
			"上海" => array(
					"" => array(),
					"" => array(),
					"" => array(),
					"" => array(),
					"" => array(),
					"" => array(),
					"" => array(),
					"" => array(),
					"" => array(),
					"" => array(),
			),
			"北京" => array(
						
			),
			"天津" => array(
						
			),
			"成都" => array(
						
			),
			"" => array(
						
			)
	);

    public function init()
    {
        /* Form Elements & Other Definitions Here ... */
    	$this->setMethod('post');
    	
    	//$user = new Zend_Form_SubForm();
    	
    	$this->addElement('text', 'mobile_tel', array(
    			'label'      => '手机号码*:',
    			'required'   => true,
    			'filters'    => array('StringTrim'),
    			'validators' => array(
    					array('regex', false, '/^(13[0-9]|14[5|7]|15[0-9]|18[0-9])\d{8}$/')
    			)
    	));
    	    	
    	$this->addElement('password', 'password', array(
    			'label'      => '输入密码*:',
    			'required'   => true,
    			'filters'    => array('StringTrim'),
    			'validators' => array(
    					array('validator' => 'StringLength', 'options' => array(6, 32))
    			)
    	));
    	
    	$psd2 = new Zend_Form_Element_Password('password_confirm');
    	$psd2->setLabel('确认密码*:')
    	->setRequired('true')
    	->addFilter(new Zend_Filter_StringTrim())
    	->addValidator(new Zend_Validate_Identical('password'))
    	->addValidator('StringLength', true, array(6,32));
    	$this->addElement($psd2);
    	 
    			
    	/* $this->addElement('password', 'password_confirm', array(
    			'label'      => '确认密码*:',
    			'required'   => true,
    			'validators' => array(
    					array('validator' => 'StringLength', 'options' => array(0, 32))
    			)
    	)); */
    	

    	
    	$this->addElement('text', 'name', array(
    			'label'      => '姓名:',
    			'required'   => false,
    			'validators' => array(
    					
    			)
    	));
    	 
    	
    	$this->addElement('text', 'email', array(
    			'label'      => '电子邮件:',
    			'required'   => false,
    			'filters'    => array('StringTrim'),
    			'validators' => array(
    					'EmailAddress'
    			)
    	));
    	
    	//$address = new Zend_Form_SubForm();
    	
    	/* 
    	
    	$province = new Zend_Form_Element_Select('province');
    	$province->addLabel('省、直辖市、自治区');
    	$this->addElement($province);
    	
    	 */
    	
    	
    	
    	$this->addElement('submit', 'submit', array(
    			'ignore'   => true,
    			'label'    => '注册',
    	));
    	
    	// And finally add some CSRF protection
    	$this->addElement('hash', 'csrf', array(
    			'ignore' => true,
    	));
    	 
    	$this->setDecorators(array(//error info
    			'FormElements',
    			array('HtmlTag', array('tag' => 'dl', 'class' => 'zend_form')),
    			array('Description', array('placement' => 'prepend')),
    			'Form'
    	));
    }

    

}

